$(function () {
    //加载表格数据
    $('#grid').datagrid({
        singleSelect: true,
        pagination: true,
        fitColumns: true,
        url: 'storeoper_listByPage',
        columns: [[
            {field: 'uuid', title: '编号'},
            {field: 'empName', title: '员工'},
            {field: 'opertime', title: '操作时间', formatter: formatDate},
            {field: 'storeName', title: '仓库'},
            {field: 'goodsName', title: '商品'},
            {field: 'num', title: '数量'},
            {
                field: 'type', title: '入库/出库', formatter: function (value, row, index) {
                return value == 1 ? '入库' : '出库';
            }
            }
        ]]
    });


    //点击查询按钮
    $('#btnSearch').bind('click', function () {
        var formData = $('#searchForm').serializeJSON();
        $('#grid').datagrid('load', formData);
    });


    /**
     * 格式化日期
     * @param value
     */
    function formatDate(value) {
        return new Date(value).Format('yyyy-MM-dd hh:mm:ss')
    }
})
